import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * Inventory class which tracks inventory and
 * has numerous operations available to 
 * manipulate inventory of the vending machine.
 * @author Prince Kishore
 * @author Phat Le
 * @author Fahad Muzaffar
 * @version 1.0
 *
 */
public class Inventory {

	/**
	 * Units of sugar.
	 */
	private static int units_sug;
	/**
	 * Units of milk.
	 */
	private static int units_mil;
	/**
	 * Units of Coffee.
	 */
	private static int units_cof;
	/**
	 * Units of Chocolate.
	 */
	private static int units_cho;
	/**
	 * Units of Bouillon.
	 */
	private static int units_bou;

	/**
	 * Empty Constructor.
	 */
	public Inventory() {
	}
	
	/**
	 * Displays the inventory of Sugar, Milk, Coffee,
	 * Chocolate, and Bouillon then returns to main
	 * menu.
	 */
	static void checkInventory () {
		System.out.println("\nSugar: " + units_sug);
		System.out.println("Milk: " + units_mil);
		System.out.println("Coffee: " + units_cof);
		System.out.println("Chocolate: " + units_cho);
		System.out.println("Bouillon: " + units_bou + "\n");
		AcmeVendingMachine.mainMenu();
	} 
	
	/**
	 * Adds new Inventory. Will ask for units of sugar,
	 * milk, coffee, chocolate, and bouillion.
	 * Also confirms upon adding inventory success.
	 */
	static void  AddInventory () {
		 final BufferedReader my_breakline = new BufferedReader(new InputStreamReader(System.in));
		//ObjectInputStream input = null;
		System.out.println("\n\n");
		try{
			System.out.println("Enter units of sugar: ");
			if(AcmeVendingMachine.checkInt(my_breakline.readLine(), AcmeVendingMachine.getMessage1(), AcmeVendingMachine.getMessage1())){
				units_sug += AcmeVendingMachine.getIntNumber();
			}
			System.out.println("Enter units of milk: ");
			if(AcmeVendingMachine.checkInt(my_breakline.readLine(), AcmeVendingMachine.getMessage1(), AcmeVendingMachine.getMessage1())){
				units_mil += AcmeVendingMachine.getIntNumber();
			}
			System.out.println("Enter units of coffee: ");
			if(AcmeVendingMachine.checkInt(my_breakline.readLine(), AcmeVendingMachine.getMessage1(), AcmeVendingMachine.getMessage1())){
				units_cof += AcmeVendingMachine.getIntNumber();
			}
			System.out.println("Enter units of chocolate: ");
			if(AcmeVendingMachine.checkInt(my_breakline.readLine(), AcmeVendingMachine.getMessage1(), AcmeVendingMachine.getMessage1())){
				units_cho += AcmeVendingMachine.getIntNumber();
			}
			System.out.println("Enter units of bouillon: ");
			if(AcmeVendingMachine.checkInt(my_breakline.readLine(), AcmeVendingMachine.getMessage1(), AcmeVendingMachine.getMessage1())){
				units_bou += AcmeVendingMachine.getIntNumber();
			}
		} catch(IOException e){
			System.out.println(AcmeVendingMachine.getMessage1());
		}
		//System.out.println();
		System.out.println("\nInventory added, thank you");
		AcmeVendingMachine.mainMenu();
	}
	
	/**
	 * Check Inventory is sufficient or not.
	 */
	static boolean checkInventorySufficience(){
		return Recipe.recipeArray[AcmeVendingMachine.item].sugar <= units_sug && 
				Recipe.recipeArray[AcmeVendingMachine.item].milk <= units_mil &&
				Recipe.recipeArray[AcmeVendingMachine.item].coffee <= units_cof &&
				Recipe.recipeArray[AcmeVendingMachine.item].chocolate <= units_cho &&
				Recipe.recipeArray[AcmeVendingMachine.item].bouillon <= units_bou;
	}
	
	/**
	 * Gets the units of sugar.
	 * @return units of sugar
	 */
	public static int getUnitsSug()
	{
		return units_sug;
	}
	
	/**
	 * Sets the units for sugar.
	 * @param sug units of sugar
	 */
	public static void setUnitsSug(int sug) {
		units_sug = sug;
	}
	
	/**
	 * Gets units of milk.
	 * @return units of milk
	 */
	public static int getUnitsMil()
	{
		return units_mil;
	}
	
	/**
	 * Sets units of milk.
	 * @param mil units of milk
	 */
	public static void setUnitsMil(int mil) {
		units_mil = mil;
	}
	
	/**
	 * Get units of coffee.
	 * @return units of coffee
	 */
	public static int getUnitsCof()
	{
		return units_cof;
	}
	
	/**
	 * Sets unit of coffee.
	 * @param cof unit of coffee
	 */
	public static void setUnitsCof(int cof) {
		units_cof = cof;
	}
	
	/**
	 * Gets units of Chocolate.
	 * @return units of chocolate
	 */
	public static int getUnitsCho()
	{
		return units_cho;
	}
	
	/**
	 * Sets units of Chocolate
	 * @param cho units of chocolate
	 */
	public static void setUnitsCho(int cho) {
		units_cho = cho;
	}
	
	/**
	 * Gets units of Bouillon.
	 * @return units of Bouillon
	 */
	public static int getUnitsBou()
	{
		return units_bou;
	}
	
	/**
	 * Sets units of Bouillon.
	 * @param bou units of Bouillon
	 */
	public static void setUnitsBou(int bou) {
		units_bou = bou;
	}
	
}
